1. Technical Field
The present invention relates in general to a method and system for data processing and in particular to an improved method and system for instruction level tracing. Still more particularly, the present invention relates to a method and system for direct access to code by taking a trace by way of an interruption without having to allocate any memory or modify the code being traced.
2. Description of the Related Art
Conventionally, code debugging in a data processing or computer system can be accomplish by either inserting calls to a tracing code routine (i.e. instrumenting) in the code to be traced, or using the tracing facility of the system to single step through the code (i.e., generate an interruption after the execution of each instruction). When using the instrumentation technique by inserting calls to a tracing code routine, the first step of the routine is typically to locate the basic blocks of the code to be traced which is usually a non-trivial and slow operation especially on data processing systems with dynamic branches like the PowerPC line of microprocessors available from IBM Microelectronics. Additionally, when using the tracing facility of the machine, tracing becomes quite slow due to the fact that the flow of instruction is interrupted each instruction due to single stepping through the code.
Also, when utilizing the instrumentation approach, it is always necessary for the tracing code routine to allocate memory for each basic block traced. At the very least, the instruction replaced by a branch to the tracing code routine has to be allocated and saved to memory. The amount of memory necessary to complete this task may be considerable, mainly because all the basic blocks in the workload to be traced have to be instrumented because it is not known in advance which one will be executed. Lastly, on the PowerPC.TM. line of microprocessors available from IBM Microelectronics (e.g., the PowerPC.TM. 604) there is also a limit of 26 bits that can be used for branch displacements. This causes limitations on what can be instrumented with big executables.
Consequently, it would be desirable to provide an improved method and system that does not have any limitation on the number of basic blocks that can be traced. In particular, it would be desirable to provide an improved method and system which utilizes tracing by way of an interruption to directly access code without having to allocate memory.